sched: fix locking for insert_vcpu() in credit1 and RTDS
authorDario Faggioli <dario.faggioli@citrix.com>
Tue, 24 Nov 2015 13:48:34 +0000 (14:48 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 24 Nov 2015 13:48:34 +0000 (14:48 +0100)
commitae2f41e3d7e7798537b7ea6dbb9a0c6aeb1179e3
tree8e13522a2e02b9b628e625da0597811eafdc8f52
parente4fd700e06c116f6198888a90552349b67aa64fa
sched: fix locking for insert_vcpu() in credit1 and RTDS

The insert_vcpu() hook is handled with inconsistent locking.
In fact, schedule_cpu_switch() calls the hook with runqueue
lock held, while sched_move_domain() relies on the hook
implementations to take the lock themselves (and, since that
is not done in Credit1 and RTDS, such operation is not safe
in those cases).

This is fixed as follows:
 - take the lock in the hook implementations, in specific
   schedulers' code;
 - avoid calling insert_vcpu(), for the idle vCPU, in
   schedule_cpu_switch(). In fact, idle vCPUs are set to run
   immediately, and the various schedulers won't insert them
   in their runqueues anyway, even when explicitly asked to.

While there, still in schedule_cpu_switch(), locking with
_irq() is enough (there's no need to do *_irqsave()).

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Reviewed-by: Meng Xu <mengxu@cis.upenn.edu>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
xen/common/sched_credit.c
xen/common/sched_rt.c
xen/common/schedule.c